﻿package app.view 
{
    import app.model.DataProxy;
    import flash.display.*;
    import org.puremvc.as3.interfaces.IMediator;
    import org.puremvc.as3.interfaces.INotification;
    import org.puremvc.as3.patterns.mediator.Mediator;
    import app.ApplicationFacade;
    import app.view.vc.*;
    import app.model.vo.Config;
    
    /**
    * author lzyy
    * Email:healdream@gmail.com
    * Blog:http://lab.lzyy.name/blog
    */
    public class StageMediator extends Mediator implements IMediator
    {
        public static const NAME:String = 'StageMediator';
        public function StageMediator(vc) 
        {
            super(NAME, vc);
        }
        
        override public function listNotificationInterests():Array 
        {
            return [ApplicationFacade.INIT];            
        }

        override public function handleNotification( note:INotification ):void
        {
            switch(note.getName())
            {
                case ApplicationFacade.INIT:
                    _addChildren();
                    break;
            }
        }
        
        private function _addChildren()
        {
            var stage = root.stage;
            
            //添加图片
            var img = new Img();
            stage.addChild(img);
            facade.registerMediator(new ImgMediator(img));
			//添加按钮
            var btns = new NumberBtns()
            stage.addChild(btns);
            facade.registerMediator(new NumberBtnsMediator(btns));
			//添加文字说明
			stage.addChild(root.Intro);
			facade.registerMediator(new IntroMediator(root.Intro));
        }
        
        public function get root()
        {
            return viewComponent as DisplayObject;
        }
        
    }
    
}